package controllers;
import java.util.Random;
import javax.faces.bean.ManagedProperty;
import javax.faces.event.ActionEvent;

import dto.DTOUser;


public class PassController {
	/**
	 * Ienei Robert
	 * generates a new password
	 */
	@ManagedProperty(value="userDto")
	DTOUser userDto;
	
	private final String base = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	private String pass;
	
	public void setPass(String pass) {
		this.pass = pass;
	}

	public DTOUser getUserDto() {
		return userDto;
	}

	public void setUserDto(DTOUser userDto) {
		this.userDto = userDto;
	}

	public String getPass() {
		return pass;
	}

	public PassController() {
		this.pass="";
	}

	public void generate(ActionEvent actionEvent){
		pass="";
		Random rand = new Random();
		for (int i=0;i<6;i++){
			String c = String.valueOf(base.charAt(rand.nextInt(base.length())));
			pass+=c;
		}
		userDto.setPassword(pass);
	}
	

}
